package hhm.android.myframe;

import android.os.Bundle;
import android.view.WindowManager;

import androidx.fragment.app.Fragment;

import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import hhm.android.base.activity.mainActivity.ButtonResourceBean;
import hhm.android.base.activity.mainActivity.MainActivity;
import hhm.android.library.LogUtils;

public class SecondActivity extends MainActivity {

    private int statusBarHeightPx;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        getWindow() .addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        super.onCreate(savedInstanceState);

        statusBarHeightPx = getStatusBarHeightPx();

        ArrayList<Fragment> list = new ArrayList<>();
        list.add(new BlankFragment2(statusBarHeightPx));
        list.add(new BlankFragment2(statusBarHeightPx));
        list.add(new BlankFragment("three"));
        list.add(new BlankFragment("four"));
        list.add(new BlankFragment("five"));
        ArrayList<ButtonResourceBean> l = new ArrayList<>();
        l.add(new ButtonResourceBean("t1", R.mipmap.one, R.mipmap.one, R.mipmap.one_blue, false));
        l.add(new ButtonResourceBean("t2", R.mipmap.two, R.mipmap.ic_launcher, R.mipmap.two_blue, true));
        l.add(new ButtonResourceBean("t3", R.mipmap.three, R.mipmap.three, R.mipmap.three_blue, true));
        l.add(new ButtonResourceBean("t4", R.mipmap.four, R.mipmap.four, R.mipmap.four_blue, true));
        l.add(new ButtonResourceBean("t5", R.mipmap.five, R.mipmap.five, R.mipmap.five_blue, true));
        setFragmentAndButton(list, l, R.color.blue, (index, fragment) -> {
//            if (index == 0 || index == 1) {
//
//            } else {
//                setTitleWhiteAndTextBlank();
//            }
        });


        byte[] buffer = new byte[]{0x01, 0xFE - 0xff};
        int percent = Integer.valueOf("" + (buffer[0] & 0xff + buffer[1] & 0xff), 16);
        LogUtils.Companion.d("hhm", "byte 16 ---> 10  :result:    " + percent);

        String s = "01fe";

        int covert = covert(s.toUpperCase());
        LogUtils.Companion.d("hhm", "byte 16 ---> 10  :result:    " + covert);

    }

    /**
     * @param: [content]
     * @return: int
     * @description: 十六进制转十进制
     */
    public static int covert(String content) {
        int number = 0;
        String[] HighLetter = {"A", "B", "C", "D", "E", "F"};
        Map<String, Integer> map = new HashMap<>();
        for (int i = 0; i <= 9; i++) {
            map.put(i + "", i);
        }
        for (int j = 10; j < HighLetter.length + 10; j++) {
            map.put(HighLetter[j - 10], j);
        }
        String[] str = new String[content.length()];
        for (int i = 0; i < str.length; i++) {
            str[i] = content.substring(i, i + 1);
        }
        for (int i = 0; i < str.length; i++) {
            number += map.get(str[i]) * Math.pow(16, str.length - 1 - i);
        }
        return number;
    }
}
